package cn.lg.zookeeper.zklock;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;

public class SimpleLock {
public static void main(String[] args) throws IOException {
	String connectString ="127.0.0.1:2181";
	int sessionTimeout =5000;
	final CountDownLatch countDownLatch = new CountDownLatch(1);
	ZooKeeper zooKeeper = new ZooKeeper(connectString, sessionTimeout ,new Watcher() {

		@Override
		public void process(WatchedEvent event) {
			// TODO Auto-generated method stub
			if(event.getType().equals(KeeperState.SyncConnected)) {
				countDownLatch.countDown();
			}
		}
		
	});
}
}
